Application note: Texture Support and Texture Limits

To apply a texture onto a surface properly, the FS viewer needs to know for any triangle of the surface and for any vertex of the triangle its exact position with respect to the texture. Assigning a pixel to every vertex would drive you nuts very quickly. The intent of the texture support is to help you in that process. Let us take an example: cast the MYTEXTURE texture onto the sub-assy MYSUB. To do that, we shall answer three questions:


These three items are disscussed in detail, then a recap shows you how to proceed to assign a texture to a sub-assy. At the end of this page, it is shown how to assign several texture supports to the same sub-assy in order to cast a different image on the different faces of it.


Which orientation are we considering for the texture?

AD2K2 gives us 6 different options :

The right option means that the left part of the texture applies on the aft part of the model in a side view and that the right part of the texture applies on the fore part of the model in a side view. The left option means the opposite (the left part of the texture applies on the fore part of the model in a side view and the right part of the texture applies on the aft part of the model in a side view).

The top option means that the left part of the texture applies on the left part of the model in a top view and that the right part of the texture applies on the right part of the model in a top view. The bottom option means the opposite.

The fore option means that the left part of the texture applies on the right part of the model in a front view (looking at the model from the front, you see its right wing on your left, don't you?) and that the right part of the texture applies on the left part of the model in a front view. The aft option means the opposite.


Which are the limits of the area to be covered (introducing the texture support) ?

Unless you want it, the texture does not fit exactly the sub-assy dimensions. Sometimes, the same texture file is used with several sub-assies. In some other cases, the texture comprises several views of the same sub-assy: the right view and the left one, for instance. It means that the texture would virtually encompass a larger thing than the sub-assy. Let us suppose that MYSUB is a wheel. We are considering the application of a part of MYTEXTURE on it from the right. As you can see, the wheel picture occupies the left/top part of the texture. It is just one fourth of it (one half of the width, one half of the height).

Mapping the texture on a virtual area in order to fit the exact location of the wheel is uneasy. The texture support and texture limits concept makes things easier.

Let us suppose that the wheel extremities in the side view are the following:
     ymin = -2.400
     ymax = -0.200
     zmin = -4.000
     zmax = -1.800

The texture support is a polygon the extremies of which coincide with these numbers. This polygon may be a square or any other kind of polygon. Let us define a hidden triangle with the following vertices:

     x = 0.000, y = -2.400, z = -4.000
     x = 0.000, y = -0.200, z = -4.000
     x = 0.000, y = -1.000, z = -1.800

The min y coordinate is -2.400, the max y coordinate is 0.200, the min z coordinate is -4.000, the max z coordinate is -1.800: it is a good candidate for the job!


Which min and max coordinates within the texture?

As we saw before, the image to be casted on the wheel is in the left/top part of the texture. Let us talk about numbers. The position of a pixel in the texture may be represented by two numbers:


Therefore, the extremities of the area which must fit with the texture support are represented by the following numbers:

     left/top:     xp = 0.000, yp = 0.000
     right/bottom: xp = 0.500, yp = 0.500


Recap: assign a texture support and texture limits to a sub-assy

First step: declare a texture support

Use the Graphic Editor to create the triangle with the following vertices:
     x = 0.000, y = -2.400, z = -4.000
     x = 0.000, y = -0.200, z = -4.000
     x = 0.000, y = -1.000, z = -1.800

Give it the hidden attribute and store it into the MYSUB sub-assy. Declare it as a texture support (Utilities/Define chain as support menu option).

Second step: assign the MYTEXTURE texture to the MYSUB sub-assy

Select the MYSUB sub-assy in the sub-assy panel. Open the sub-assy code window by clicking on the open instruction window button of the sub-assy panel tool-bar. Click on the select a texture button of the sub-assy code window tool-bar. Select the MYTEXTURE texture in the texture selection window. If it is not available in the list, click on the open button to find it. Validate to go back to the sub-assy code window.

Tip: It is recommended to have all the texture files inside the project directory. If one is missing, you will not be able to assign it texture limits.

To get information on the options available in the sub-panel which is below the texture list, please refer to the section of this tutorial dedicated to the texture allocation system used by FS.

Third step: assign the texture support

In the sub-assy code window, the first instruction in the list is a LIMITS instruction. It is assigned an undefined texture support. Double-click on the instruction. The texture support selection window is displayed. To the right of the window, there is a small sub-panel with two arrows: one is pointing to the left, the other one to the right. Click on one of the arrows. As you have declared the required texture support just before, it is loaded at once. The texture support extremities are displayed below the pair of arrows. Make sure you have selected the side option.

Tip: The same texture support can be used with several sub-assies. To load it if it is not available at the first click on an arrow, click again.

Fourth step: assign the limits within the texture

If the texture file is in the project directory, it is displayed to the left of the window. The default limits are
     left/top =     0.000, 0.000
     right/bottom = 1.000, 1.000

meaning that the whole texture is used. Click on the limits button. Move the cursor over the texture image and click on the left/top corner. A red cross is super-imposed on the image. Click on the small OK button to validate the left/top extremity. Move again the cursor over the image. Look at the area located between the two arrows. The coordinates of the cursor are displayed. Make sure you are at the center of the texture and click. A red square is drawn which encompass the selected area. Make sure the good orientation is selected (right radio-button). Validate by clicking on the OK button. Exit the texture support selection window. The LIMITS instruction is updated to reflect the selected texture support and limits. This is it!

Tip: Selecting a wrong direction in the texture support selection window (right instead of left, top instead of lower, fore instead of aft...) results in a reversed image.


Applying several texture supports to the same sub-assy
You cannot assign several textures to a single sub-assy but you can assign it several texture supports. Most of the time, you have to do that. Let us take another example: the sub-assy MYWING is a wing, the texture to be applied is stored into the WINGTEX file. You do not want to apply the same image on top and underneath, do you? Let us assume that the WINGTEX texture is composed of two parts: the upper-half of it is the top view of the wing, the lower-half is the bottom view.

To initialize the process, draw a chain which encompass the wing in the top view, give it the hidden attribute and declare it as a texture support. Open the sub-assy code window and assign the WINGTEX file to the sub-assy. Double-click on the first instruction which is a LIMITS instruction. In the texture selection window, click on the top radio button and load the appropriate texture support.

We shall start with the top view. Click on the limits button and select the upper-half area:
     left/top:     xp = 0.000, yp = 0.000
     right/bottom: xp = 1.000, yp = 0.500

Make sure the top view option is checked before you validate.

This applies the upper view on top of the wing and underneath it. That is not what we want. Go back to the Graphic Editor. Select the MYWING sub-assy. Activate the multiple selection mode by clicking on the multiple selection button in the tool-bar. Use the C key and the space key of the keyboard to select all the triangles of the lower face of the wing. Keep the multiple selection mode activated and open the MYWING sub-assy code window. You can see that a lot of TRIANGLE instructions are selected. These are the triangles that you have just selected before. Click on the arrow pointing to the bottom in the tool-bar (move at bottom). All the selected instructions are gathered at the bottom of the list.

Cool, isn't it? Click now on the first selected instruction. It is now the only one. Click on the insert a texture limit instruction button in the tool-bar: a new LIMITS instruction is inserted with an undefined texture limit. Double-click on it to open the texture support selection window. In the texture support selection window check the top radio button and load the texture support that we already used to define the upper view.

To assign the lower part of the texture, click on the limits button. Select the lower-half of the image:
     left/top:     xp = 0.000, yp = 0.500
     right/bottom: xp = 1.000, yp = 1.000

Make sure the lower view option is checked before you validate.

Let us summarize. The first LIMITS instruction assigns the upper-half of the texture to the triangles immediately following it. As we gathered the triangles of the lower face of the wing at the end of the list, the triangles on top of the list are the triangles of the upper face. Then the second LIMITS instruction assigns the lower-half of the texture to the triangles at the end of the list... which are the triangles of the lower face. This is it!


copyright Hervé Devred 2003